<?php

namespace App\Library\Requests\Auction;

use App\Library\Requests\Base\BaseDTORequest;
use App\Library\Rules\MediaVideoRule;

class AuctionAddRequest extends BaseDTORequest
{
    public function rules(): array
    {
        return [
            'title' => 'required|string|max:30',//标题
            'status' => 'required|integer|in:0,1',//状态:1上架0下架
            'categoryId' => 'required|integer|min:1',//三级分类
            'isProtect' => 'required|integer|in:0,1',//是否为保护动物
            'isFeral' => 'required|integer|in:0,1',//0家养动物1野生
            'brand' => 'nullable|string|max:30',//品牌
            'stage' => 'nullable|integer|between:0,3',//阶段:1苗子2亚成3成体
            'gene' => 'nullable|string|max:30',//基因
            'tag' => 'nullable|array|max:10',//标签
            'remark' => 'nullable|string|max:255',//备注
            'description' => 'nullable|string',//详情
            'eat' => 'nullable|string|max:30',//喂养饲料
            'guide' => 'nullable|string|max:30',//指南
            'startPrice' => 'required|decimal:2',//起拍价
            'bailPrice' => 'required|decimal:2',//保证金
            'cappingPrice' => 'nullable|decimal:2',//一口价
            'startAt' => 'required|date|date_format:Y-m-d H:i:s',//有效开始时间
            'endAt' => 'required|date|date_format:Y-m-d H:i:s|after:startAt',//有效结束时间
            'sourceNumber' => 'nullable|string|max:30',//溯源编码
            'inc' => 'required|decimal:2',//加价幅度
            'freight' => 'required|integer|min:0',//运费
            'mainImgIds' => 'nullable|array|max:10',//主图
            'descImgIds' => 'nullable|array|max:10',//详情图
            'videoId' => ['nullable', 'string', 'size:20', new MediaVideoRule],//视频
            'fileId' => 'nullable|string|size:20|regex:' . __('com.numReg'),
            'publishId' => 'nullable|integer|min:1',
            'categoryIdOne' => 'nullable|integer|min:1',//一级分类
            'categoryIdTwo' => 'nullable|integer|min:1',//二级分类
            'categoryIdThree' => 'nullable|integer|min:1',//三级分类
//            'onePushStatus' => 'required|integer|in:0,1',
            'onePush' => 'nullable|array',
            'twoPush' => 'nullable|array',
            'recommend' => 'nullable|boolean',
            'sort' => 'nullable|integer|min:0',
        ];
    }

    public function message(): array
    {
        return [
            'endAt.after' => '拍卖结束时间必须大于拍卖开始时间',
        ];
    }

    public function attributes(): array
    {
        return [
            'startAt' => '拍卖开始时间',
            'endAt' => '拍卖结束时间',
        ];
    }
}
